package com.file.io;

import java.io.IOException;
import java.io.Serializable;

public class StudentDemo implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String stuNo;
	private String stuName;
	private transient int stuAge; //该元素不会进行jvm默认的序列化，但可自行序列化；
								// 某些情况下可提高效率
	
	public StudentDemo(){
		
	}
	
	public StudentDemo(String stuNo, String stuName, int stuAge) {
		super();
		this.stuNo = stuNo;
		this.stuName = stuName;
		this.stuAge = stuAge;
	}

	public String getStuNo() {
		return stuNo;
	}
	public void setStuNo(String stuNo) {
		this.stuNo = stuNo;
	}
	public String getStuName() {
		return stuName;
	}
	public void setStuName(String stuName) {
		this.stuName = stuName;
	}
	public int getStuAge() {
		return stuAge;
	}
	public void setStuAge(int stuAge) {
		this.stuAge = stuAge;
	}
	@Override
	public String toString() {
		return "StudentDemo [stuNo=" + stuNo + ", stuName=" + stuName + ", stuAge=" + stuAge + "]";
	}
	
	private void writeObject(java.io.ObjectOutputStream s) throws IOException {
		s.defaultWriteObject(); //把jvm能默认序列化的元素进行序列化操作
		s.writeInt(stuAge); //自行完成stuAge序列化
	}
	
	private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, IOException {
		s.defaultReadObject();	//把jvm能默认反序列化的元素进行反序列化操作
		this.stuAge = s.readInt(); //自己完成stuage的反序列化操作
	}
}
